package swagger.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import swagger.demo.pojo.User;

//operation接口
 @ApiOperation("Hello控制器")
@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }

    //只有我的接口返回值中存在实体类他就会被扫描到
    @PostMapping("/user")
    public User user() {
        return new User();
    }

    //Operation接口
    @ApiOperation("Hello控制类")
    @GetMapping(value = "/hello2")
    public String hello2(@ApiParam("用户名") String username){
        return "hello"+username;
    }

    @ApiOperation("Post控制类")
    @GetMapping(value = "/postt")
    public User postt(@ApiParam("Post_test") User user){
        return user;
    }
}